<!--
 * @Description: 
 * @Autor: ZachGmy
 * @Date: 2021-06-21 11:29:50
 * @LastEditors: ZachGmy
 * @LastEditTime: 2021-06-21 14:48:23
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 子元素的宽高 */
    div {
      width: 50px;
      height: 50px;
    }

    /* 父元素的宽高 */
    .father {
      width: 300px;
      height: 200px;
      background-color: gray;
      margin: 100px auto;
      display: flex;
      /* 交叉轴对齐的方式 */
      align-items: center;
      /* 主轴的对齐方式 */
      justify-content: center;
    }
  </style>
</head>

<body>
  <div class="father">
    <div style="background-color: red;">1</div>
    <div style="background-color: blue;">2</div>
    <div style="background-color: yellow;">3</div>
  </div>
</body>

</html>